package com.cygnus.model;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.validation.constraints.Email;
import javax.validation.constraints.Pattern;

@Data
@NoArgsConstructor
public class Employee {
    private Integer empId;

    @Pattern(regexp = "(^[a-zA-Z0-9_-]{6,15}$)|(^[\\u4e00-\\u9fa5·]{2,10})"
            ,message = "Hibernate后端验证:用户名必须是6到15位英文数字组合或2到10位中文")
    private String empName;

    private String gendar;

    @Pattern(regexp = "^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"
            ,message = "Hibernate后端验证:邮箱格式不正确")
    private String email;

    private Integer dId;

    private Department department;

    public Integer getEmpId() {
        return empId;
    }

    public void setEmpId(Integer empId) {
        this.empId = empId;
    }

    public String getEmpName() {
        return empName;
    }

    public void setEmpName(String empName) {
        this.empName = empName == null ? null : empName.trim();
    }

    public String getGendar() {
        return gendar;
    }

    public void setGendar(String gendar) {
        this.gendar = gendar == null ? null : gendar.trim();
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email == null ? null : email.trim();
    }

    public Integer getdId() {
        return dId;
    }

    public void setdId(Integer dId) {
        this.dId = dId;
    }

    public Employee(String empName, String gendar, String email, Integer dId) {
        this.empName = empName;
        this.gendar = gendar;
        this.email = email;
        this.dId = dId;
    }

    public Employee(Integer empId, @Pattern(regexp = "(^[a-zA-Z0-9_-]{6,15}$)|(^[\\u4e00-\\u9fa5·]{2,10})"
            , message = "Hibernate后端验证:用户名必须是6到15位英文数字组合或2到10位中文") String empName, String gendar, @Pattern(regexp = "^[A-Za-z0-9\\u4e00-\\u9fa5]+@[a-zA-Z0-9_-]+(\\.[a-zA-Z0-9_-]+)+$"
            , message = "Hibernate后端验证:邮箱格式不正确") String email, Integer dId) {
        this.empId = empId;
        this.empName = empName;
        this.gendar = gendar;
        this.email = email;
        this.dId = dId;
    }

    //Redis 学习
    public static String getKey(){
        return "emp:";
    }
    public static String getName(){return "emp";}
}